package leecode

type ListNode24 struct {
	Val  int
	Next *ListNode24
}

func swapPairs(head *ListNode24) *ListNode24 {
	dummy := &ListNode24{
		Next: head,
	}
	pre := dummy
	for head != nil && head.Next != nil {
		pre.Next = head.Next
		next := head.Next.Next
		head.Next.Next = head
		head.Next = next
		pre = head
		head = next
	}
	return dummy.Next
}
